package mipo.top.base.controller;

import mipo.top.base.Dto.WechatDto;
import mipo.top.base.Vo.LoginphoneVo;
import mipo.top.base.service.ILoginService;
import mipo.top.base.util.JsonResult;
import mipo.top.users.Vo.LogininfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;
    @PostMapping("/account")
    public JsonResult account(@RequestBody LogininfoVo logininfoVo){
        try {
            HashMap<String, Object> map = loginService.account(logininfoVo);
            return JsonResult.me().setResultData(map);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.me().setMsg(e.getMessage());
        }
    } @PostMapping("/phoneAccount")
    public JsonResult phoneAccount(@RequestBody LoginphoneVo loginphoneVo){
        try {
            HashMap<String, Object> map = loginService.phoneAccount(loginphoneVo);
            return JsonResult.me().setResultData(map);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.me().setMsg(e.getMessage());
        }
    }
    @PostMapping("/wechat")
    public JsonResult wechat(@RequestBody WechatDto wechatDto){
        try {
            return loginService.wechat(wechatDto);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.me().setMsg(e.getMessage());
        }
    }
}
